home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / actionrp / nhplusx.bin / nhplusx / nhplusX / X11 / Window.c < prev    next >
C/C++ Source or Header  |  1995-09-10  |  5KB  |  176 lines

  1. /*    SCCS Id: @(#)Window.c    3.1    93/02/02          */
  2. /* Copyright (c) Dean Luick, 1992                  */
  3. /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5. /*
  6.  * Data structures and support routines for the Window widget.  This is a
  7.  * drawing canvas with 16 colors and one font.
  8.  */
  9.  
  10. #ifndef SYSV
  11. #define PRESERVE_NO_SYSV    /* X11 include files may define SYSV */
  12. #endif
  13.  
  14. #ifdef MSDOS            /* from compiler */
  15. #define SHORT_FILENAMES
  16. #endif
  17.  
  18. #ifdef SHORT_FILENAMES
  19. #include <X11/IntrinsP.h>
  20. #else
  21. #include <X11/IntrinsicP.h>
  22. #endif
  23. #include <X11/StringDefs.h>
  24.  
  25. #ifdef PRESERVE_NO_SYSV
  26. # ifdef SYSV
  27. #  undef SYSV
  28. # endif
  29. # undef PRESERVE_NO_SYSV
  30. #endif
  31.  
  32. #include "WindowP.h"
  33.  
  34. #include "config.h"
  35.  
  36. static XtResource resources[] = {
  37. #define offset(field) XtOffset(WindowWidget, window.field)
  38.     /* {name, class, type, size, offset, default_type, default_addr}, */
  39.     { XtNrows, XtCRows, XtRDimension, sizeof(Dimension),
  40.       offset(rows), XtRImmediate, (XtPointer) 21},
  41.     { XtNcolumns, XtCColumns, XtRDimension, sizeof(Dimension),
  42.       offset(columns), XtRImmediate, (XtPointer) 80},
  43.     { XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
  44.       offset(foreground), XtRString, XtDefaultForeground },
  45.  
  46.     { XtNblack, XtCColor, XtRPixel, sizeof(Pixel),
  47.       offset(black), XtRString, "black"},
  48.     { XtNred, XtCColor, XtRPixel, sizeof(Pixel),
  49.       offset(red), XtRString, "red" },
  50.     { XtNgreen, XtCColor, XtRPixel, sizeof(Pixel),
  51.       offset(green), XtRString, "pale green" },
  52.     { XtNbrown, XtCColor, XtRPixel, sizeof(Pixel),
  53.       offset(brown), XtRString, "brown" },
  54.     { XtNblue, XtCColor, XtRPixel, sizeof(Pixel),
  55.       offset(blue), XtRString, "blue" },
  56.     { XtNmagenta, XtCColor, XtRPixel, sizeof(Pixel),
  57.       offset(magenta), XtRString, "magenta" },
  58.     { XtNcyan, XtCColor, XtRPixel, sizeof(Pixel),
  59.       offset(cyan), XtRString, "light cyan" },
  60.     { XtNgray, XtCColor, XtRPixel, sizeof(Pixel),
  61.       offset(gray), XtRString, "gray" },
  62.     { XtNorange, XtCColor, XtRPixel, sizeof(Pixel),
  63.       offset(orange), XtRString, "orange" },
  64.     { XtNbright_green, XtCColor, XtRPixel, sizeof(Pixel),
  65.       offset(bright_green), XtRString, "green" },
  66.     { XtNyellow, XtCColor, XtRPixel, sizeof(Pixel),
  67.       offset(yellow), XtRString, "yellow" },
  68.     { XtNbright_blue, XtCColor, XtRPixel, sizeof(Pixel),
  69.       offset(bright_blue), XtRString, "royal blue" },
  70.     { XtNbright_magenta, XtCColor, XtRPixel, sizeof(Pixel),
  71.       offset(bright_magenta), XtRString, "violet" },
  72.     { XtNbright_cyan, XtCColor, XtRPixel, sizeof(Pixel),
  73.       offset(bright_cyan), XtRString, "cyan" },
  74.     { XtNwhite, XtCColor, XtRPixel, sizeof(Pixel),
  75.       offset(white), XtRString, "white" },
  76.  
  77.     { XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
  78.       offset(font), XtRString, XtDefaultFont },
  79.     { XtNexposeCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
  80.       offset(expose_callback), XtRCallback, NULL },
  81.     { XtNcallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
  82.       offset(input_callback), XtRCallback, NULL },
  83.     { XtNresizeCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
  84.       offset(resize_callback), XtRCallback, NULL },
  85. #undef offset
  86. };
  87.  
  88. extern void FDECL(map_input, (Widget, XEvent*, String*, Cardinal*));
  89.                             /* from winmap.c */
  90.  
  91. /* ARGSUSED */
  92. static void no_op(w, event, params, num_params)
  93.     Widget   w;            /* unused */
  94.     XEvent   *event;        /* unused */
  95.     String   *params;        /* unused */
  96.     Cardinal *num_params;    /* unused */
  97. {
  98. }
  99.  
  100. static XtActionsRec actions[] =
  101. {
  102.     {"input",    map_input},
  103.     {"no-op",    no_op},
  104. };
  105.  
  106. static char translations[] =
  107. "<Key>:        input()    \n\
  108.  <BtnDown>:    input() \
  109. ";
  110.  
  111. /* ARGSUSED */
  112. static void Redisplay(w, event, region)
  113.     Widget w;
  114.     XEvent *event;
  115.     Region region;    /* unused */
  116. {
  117.     /* This isn't correct - we need to call the callback with region. */
  118.     XtCallCallbacks(w, XtNexposeCallback, (caddr_t) event);
  119. }
  120.  
  121. /* ARGSUSED */
  122. static void Resize(w)
  123.     Widget w;
  124. {
  125.     XtCallCallbacks(w, XtNresizeCallback, (caddr_t) NULL);
  126. }
  127.  
  128.  
  129. WindowClassRec windowClassRec = {
  130.   { /* core fields */
  131.     /* superclass        */    (WidgetClass) &widgetClassRec,
  132.     /* class_name        */    "Window",
  133.     /* widget_size        */    sizeof(WindowRec),
  134.     /* class_initialize        */    NULL,
  135.     /* class_part_initialize    */    NULL,
  136.     /* class_inited        */    FALSE,
  137.     /* initialize        */    NULL,
  138.     /* initialize_hook        */    NULL,
  139.     /* realize            */    XtInheritRealize,
  140.     /* actions            */    actions,
  141.     /* num_actions        */    XtNumber(actions),
  142.     /* resources        */    resources,
  143.     /* num_resources        */    XtNumber(resources),
  144.     /* xrm_class        */    NULLQUARK,
  145.     /* compress_motion        */    TRUE,
  146.     /* compress_exposure    */    TRUE,
  147.     /* compress_enterleave    */    TRUE,
  148.     /* visible_interest        */    FALSE,
  149.     /* destroy            */    NULL,
  150.     /* resize            */    Resize,
  151.     /* expose            */    Redisplay,
  152.     /* set_values        */    NULL,
  153.     /* set_values_hook        */    NULL,
  154.     /* set_values_almost    */    XtInheritSetValuesAlmost,
  155.     /* get_values_hook        */    NULL,
  156.     /* accept_focus        */    NULL,
  157.     /* version            */    XtVersion,
  158.     /* callback_private        */    NULL,
  159.     /* tm_table            */    translations,
  160.     /* query_geometry        */    XtInheritQueryGeometry,
  161.     /* display_accelerator    */    XtInheritDisplayAccelerator,
  162.     /* extension        */    NULL
  163.   },
  164.   { /* window fields */
  165.     /* empty            */    0
  166.   }
  167. };
  168.  
  169. WidgetClass windowWidgetClass = (WidgetClass)&windowClassRec;
  170.  
  171. Font
  172. WindowFont(w) Widget w; { return ((WindowWidget)w)->window.font->fid; }
  173.  
  174. XFontStruct *
  175. WindowFontStruct(w) Widget w; { return ((WindowWidget)w)->window.font; }
  176.